package com.turing.model.caller.task;

import com.turing.common.util.FdfsUtils;
import com.turing.model.caller.client.task.manager.DrawClient;
import com.turing.model.caller.utils.SpringUtil;
import com.turing.model.caller.vo.in.OcrResultVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.springframework.util.ReflectionUtils;
import org.springframework.web.context.WebApplicationContext;

import java.lang.reflect.Method;

@Component
public class OcrResultCallBack {

    private static final Logger LOG = LoggerFactory.getLogger(OcrResultCallBack.class);

    @Async
    public void doCallback(OcrResultVo ocrResultVo,String client ) {

        String jsonText = ocrResultVo.getJSONText();
        String jsonUrl = FdfsUtils.uploadBytes(jsonText);
        ocrResultVo.setJSONUrl(jsonUrl);
        //drawClient.ocrResultCallback(ocrResultVo);
        Method method = SpringUtil.getMethod(client,"ocrResultCallback",OcrResultVo.class );
        ReflectionUtils.invokeMethod(method,SpringUtil.getBean(client),ocrResultVo);

    }

}
